import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from '@vant/auto-import-resolver'
import { vitePluginForArco } from '@arco-plugins/vite-vue'
import { ArcoResolver } from 'unplugin-vue-components/resolvers'
// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
    vitePluginForArco({
      style: 'css'
    }),

    AutoImport({
      resolvers: [VantResolver(), ArcoResolver()],
    }),
    Components({
      resolvers: [VantResolver(), ArcoResolver({
        sideEffect: true
      })],
    }),
    vueJsx()
  ],
  css: {
    preprocessorOptions: {
      less: {
        additionalData: `@import "./src/styles/variables.less";`,
      },
    },
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  server: {
    host: '0.0.0.0', // 允许外部访问
    port: 5173, // 设置端口号保持我的
  },
})